var app = getApp()
var pageObject = {
  data: { 
    indexOrderList: [],  
  },
  onLoad: function() { 
    var loginUserId = wx.getStorageSync('LOGINUSER_ID') || '';
    if(loginUserId == ''){
      wx.redirectTo({
        url: '../index/index?redirect=my-center/my-center'
      })
    }else{ 
      this.showOrderList();
    }
  },  
  showOrderList: function(){ 
    var loginUserId = wx.getStorageSync('LOGINUSER_ID') || '';
    var _this = this;
    wx.request({ 
      url: app.globalData.message_mylist_url + '?userId=' + loginUserId,
      data: {},
      method: 'GET', 
      success: function (res) {
        var resultData = res.data;
        if(resultData.errno == 0){
          _this.setData({indexOrderList: resultData.data}) 
        }
      },
      fail: function () {
        setTimeout(function () {
          wx.showToast({
            title: "加载失败"
          })
        }, 100)
      }
    }) 
  },  
  messagecenter:function(e){
    wx.navigateTo({
      url: '../message-center/message-center?id=' +  e.currentTarget.dataset.id +'&doctorId=' +  e.currentTarget.dataset.doctorid
    })
  } 
}

Page(pageObject)
